/*
 *  $Id: ObjectHistoryDateCompare.java,v 1.3 2006/04/06 20:26:55 vectrics Exp $
 */
package org.vectrics.history;


import java.util.*;
import org.apache.log4j.Logger;



/**
 *  Description of the Class
 *
 *@author     mmoore
 *@created    December 26, 2002
 */
public class ObjectHistoryDateCompare implements Comparator {
	static private transient Logger log = Logger.getLogger(ObjectHistoryDateCompare.class); 

    /**
     *  Constructor for the JobDeviceDateComparator object
     */
    public ObjectHistoryDateCompare() {
    	super();
    }


    /**
     *  Description of the Method
     *
     *@param  object1  First history object
     *@param  object2  Second history object
     *@return          Result of compare (see java.util.Comparator documentation)
     */
    public int compare(Object object1, Object object2) {
        ObjectHistory obj1 = (ObjectHistory) object1;
        ObjectHistory obj2 = (ObjectHistory) object2;

        int result = 0;


        result = obj1.getObjectType().compareTo(obj2.getObjectType());

        if (result == 0) {
            result = obj1.getObjectId().compareTo(obj2.getObjectId());
        }

        if (result == 0) {
            result = obj1.getDate().compareTo(obj2.getDate());
        }
        
        if (result == 0) {
            result = obj1.getPerson().getName().compareTo(obj2.getPerson().getName());
        }
        
		if (result == 0) {
			result = obj1.getId().compareTo(obj2.getId());
		}

        return (result);
    }
}

